package org.ns.framework.datasource.config;

import org.springframework.beans.factory.FactoryBean;

import java.util.function.Supplier;

public class DataSourceFactory implements FactoryBean {

    private Class<?> beanType;
    private Supplier<?> supplier;

    public DataSourceFactory(Class<?> beanType, Supplier<?> supplier) {
        this.beanType = beanType;
        this.supplier = supplier;
    }

    @Override
    public Object getObject() throws Exception {
        return supplier.get();
    }

    @Override
    public Class<?> getObjectType() {
        return beanType;
    }
}
